package com.ljh.booksysms.controller;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ljh.booksysms.service.BookInfoService;
import com.ljh.booksysms.service.impl.BookInfoServiceImpl;

@Controller
@RequestMapping(value="/bookInfo")
public class BookInfoController {
	
	@RequestMapping(value="/findAllBook")
	public Object findAllBook(Map<String, Object> resultMap, HttpServletRequest request){
		
		String likeName=request.getParameter("likeName");
		
		if (likeName!=null) {
			try {
				likeName=new String(likeName.getBytes("ISO-8859-1"),"utf-8");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		
		//创建 Map Parameter
		Map<String, Object> ParMap=new HashMap<String, Object>();
		ParMap.put("likeName", likeName);
		//调用services 事务管理层
		BookInfoService biService=new BookInfoServiceImpl();
		List<Map<String, Object>> list =biService.findAll(ParMap);
		
		//保存查询数据
		resultMap.put("list", list);
		
		return "index";
	}
}
